Real Estate Market Scanning

工作流概述

这是一个包含15个节点的复杂工作流,主要用于自动化处理各种任务。

工作流源代码

下载
{
  "id": "WUFuYk56jNNpjfZm",
  "meta": {
    "instanceId": "bb9853d4d7d87207561a30bc6fe4ece20b295264f7d27d4a62215de2f3846a56"
  },
  "name": "Real Estate Market Scanning",
  "tags": [],
  "nodes": [
    {
      "id": "db8f34be-8475-4be6-b070-79a8185fad69",
      "name": "Schedule Market Scan",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1580,
        260
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "36f4babd-3441-4da7-b485-3f9f561cb929",
      "name": "BatchData API Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        -1380,
        260
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f44f6a90-6de5-4c02-909d-73cfce0c0c9a",
              "name": "apiKey",
              "type": "string",
              "value": "YOUR_BATCHDATA_API_KEY"
            },
            {
              "id": "9356ff74-9783-40cf-a8af-94e45f1ac83e",
              "name": "searchParameters",
              "type": "object",
              "value": "={
  \"city\": \"Austin\",
  \"state\": \"TX\",
  \"minimumMarketValue\": 250000,
  \"maximumMarketValue\": 600000,
  \"minimumEquity\": 30,
  \"propertyType\": [\"SFR\"],
  \"limit\": 100
}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "e34c4c84-4b31-451f-ad16-11db76f67dce",
      "name": "Query BatchData Properties",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1180,
        260
      ],
      "parameters": {
        "url": "https://api.batchdata.com/api/v1/properties/search",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "city",
              "value": "={{ $json.searchParameters.city }}"
            },
            {
              "name": "state",
              "value": "={{ $json.searchParameters.state }}"
            },
            {
              "name": "minimumMarketValue",
              "value": "={{ $json.searchParameters.minimumMarketValue }}"
            },
            {
              "name": "maximumMarketValue",
              "value": "={{ $json.searchParameters.maximumMarketValue }}"
            },
            {
              "name": "minimumEquity",
              "value": "={{ $json.searchParameters.minimumEquity }}"
            },
            {
              "name": "propertyType",
              "value": "={{ $json.searchParameters.propertyType }}"
            },
            {
              "name": "limit",
              "value": "={{ $json.searchParameters.limit }}"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth"
      },
      "typeVersion": 4.1
    },
    {
      "id": "c6d4c4ee-51d4-41f5-a975-e979785e9166",
      "name": "Get Previous Results",
      "type": "n8n-nodes-base.code",
      "position": [
        -980,
        260
      ],
      "parameters": {
        "jsCode": "// Get the stored data from previous runs
const workflowStaticData = getWorkflowStaticData('global');

// If no previous data exists, initialize it
if (!workflowStaticData.hasOwnProperty('previousProperties')) {
  workflowStaticData.previousProperties = [];
}

// Add the previous properties data to the current item
return [
  {
    json: {
      ...items[0].json,
      previousProperties: workflowStaticData.previousProperties,
      currentProperties: items[0].json.data.properties || [],
    }
  }
];"
      },
      "typeVersion": 2
    },
    {
      "id": "a77dfe55-8a01-4b83-9395-ab533e1b7b24",
      "name": "Compare Results",
      "type": "n8n-nodes-base.code",
      "position": [
        -780,
        260
      ],
      "parameters": {
        "jsCode": "// Get the current and previous property lists
const currentProperties = items[0].json.currentProperties;
const previousProperties = items[0].json.previousProperties;

// Create a map of previous properties by their ID for easier comparison
const previousPropertiesMap = {};
for (const property of previousProperties) {
  previousPropertiesMap[property.id] = property;
}

// Find new properties (those in current but not in previous)
const newProperties = currentProperties.filter(property => 
  !previousPropertiesMap[property.id]
);

// Find changed properties (those in both but with different values)
const changedProperties = currentProperties.filter(property => {
  const previousProperty = previousPropertiesMap[property.id];
  if (!previousProperty) return false;
  
  // Check if important values changed (price, status, etc.)
  return (
    property.marketValue !== previousProperty.marketValue ||
    property.status !== previousProperty.status ||
    property.ownerStatus !== previousProperty.ownerStatus ||
    property.lastSaleDate !== previousProperty.lastSaleDate
  );
});

// Update the static data for the next run
const workflowStaticData = getWorkflowStaticData('global');
workflowStaticData.previousProperties = currentProperties;

// Return the combined results
return [
  {
    json: {
      ...items[0].json,
      newProperties,
      changedProperties,
      allChanges: [...newProperties, ...changedProperties]
    }
  }
];"
      },
      "typeVersion": 2
    },
    {
      "id": "c8c01396-58e8-4782-b1aa-0cc3059ef80f",
      "name": "Split Properties",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -560,
        260
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "allChanges"
      },
      "typeVersion": 1
    },
    {
      "id": "7971a981-d2e8-4d96-b3ef-ad6e532d95fe",
      "name": "Filter High Potential",
      "type": "n8n-nodes-base.filter",
      "position": [
        -380,
        260
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "83c15f54-20d9-460c-a3f5-82f6c98d3d63",
              "operator": {
                "type": "number",
                "operation": "larger"
              },
              "leftValue": "={{ $json.equityPercentage || 0 }}",
              "rightValue": 40
            },
            {
              "id": "53bf77b8-4c78-4f87-a518-0e9a56c77a70",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json.ownerStatus || '' }}",
              "rightValue": "absentee"
            }
          ]
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "f5c20b50-d514-4d26-a3e7-874f228578e9",
      "name": "Get Property Details",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -180,
        260
      ],
      "parameters": {
        "url": "=https://api.batchdata.com/api/v1/properties/{{ $json.id }}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "typeVersion": 4.1
    },
    {
      "id": "f83e4ccb-4457-4e00-97b7-ad411decba80",
      "name": "Format Email Content",
      "type": "n8n-nodes-base.set",
      "position": [
        20,
        260
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "ad37cef8-0359-4fb8-8c54-e5a5a0aa1082",
              "name": "emailSubject",
              "type": "string",
              "value": "=New Property Opportunity: {{ $json.address.street }}, {{ $json.address.city }}, {{ $json.address.state }}"
            },
            {
              "id": "9c1b6e34-b31e-4e46-a6b3-ea7c34b4456a",
              "name": "emailContent",
              "type": "string",
              "value": "=<h2>High Potential Property Opportunity</h2>

<p><strong>Address:</strong> {{ $json.address.street }}, {{ $json.address.city }}, {{ $json.address.state }} {{ $json.address.zip }}</p>

<p><strong>Property Details:</strong></p>
<ul>
  <li>Market Value: ${{ $json.marketValue }}</li>
  <li>Equity: {{ $json.equityPercentage }}%</li>
  <li>Owner Status: {{ $json.ownerStatus }}</li>
  <li>Square Feet: {{ $json.squareFeet }}</li>
  <li>Bedrooms: {{ $json.bedrooms }}</li>
  <li>Bathrooms: {{ $json.bathrooms }}</li>
  <li>Year Built: {{ $json.yearBuilt }}</li>
  <li>Last Sale Date: {{ $json.lastSaleDate }}</li>
  <li>Last Sale Price: ${{ $json.lastSalePrice }}</li>
</ul>

<p><strong>Owner Information:</strong></p>
<ul>
  <li>Owner Name: {{ $json.owner.name }}</li>
  <li>Mailing Address: {{ $json.owner.mailingAddress }}</li>
  <li>Phone Numbers: {{ $json.owner.phoneNumbers ? $json.owner.phoneNumbers.join(', ') : 'N/A' }}</li>
  <li>Email: {{ $json.owner.email || 'N/A' }}</li>
</ul>

<p>This property appears to be a high-potential opportunity based on:</p>
<ul>
  <li>High equity percentage</li>
  <li>Absentee owner</li>
</ul>

<p><a href=\"https://maps.google.com/?q={{ $json.address.street }}, {{ $json.address.city }}, {{ $json.address.state }} {{ $json.address.zip }}\">View on Google Maps</a></p>"
            },
            {
              "id": "eac4a51e-edfe-457a-9b38-a6c6f9e17ffd",
              "name": "slackMessage",
              "type": "string",
              "value": "=*New High Potential Property Lead*

*Address:* {{ $json.address.street }}, {{ $json.address.city }}, {{ $json.address.state }} {{ $json.address.zip }}
*Market Value:* ${{ $json.marketValue }}
*Equity:* {{ $json.equityPercentage }}%
*Owner Status:* {{ $json.ownerStatus }}

<https://maps.google.com/?q={{ $json.address.street }}, {{ $json.address.city }}, {{ $json.address.state }} {{ $json.address.zip }}|View on Google Maps>"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "3f69ccd0-24c8-490f-a1ec-305f14819d39",
      "name": "Send Email Alert",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        400,
        180
      ],
      "webhookId": "efb002e7-21e3-483c-9a4f-f95f400ad203",
      "parameters": {
        "options": {},
        "subject": "={{ $json.emailSubject }}",
        "toEmail": "salesteam@yourcompany.com",
        "fromEmail": "alerts@yourcompany.com"
      },
      "typeVersion": 2
    },
    {
      "id": "416661ac-8068-44fd-b95f-6b978834eed9",
      "name": "Post to Slack",
      "type": "n8n-nodes-base.slack",
      "position": [
        280,
        320
      ],
      "webhookId": "b50cadef-1223-47fa-bf5f-1512b4c323f0",
      "parameters": {
        "text": "={{ $json.slackMessage }}",
        "otherOptions": {}
      },
      "typeVersion": 2
    },
    {
      "id": "f6b33048-3224-4b2d-a3e3-fd21dc1f42aa",
      "name": "Sticky Note Main Flow",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1660,
        120
      ],
      "parameters": {
        "width": 1040,
        "height": 340,
        "content": "## Main Workflow Flow
This part of the workflow handles the regular scanning and processing of property data. It runs on a schedule to detect new properties or changes to existing ones, then passes the filtered results along for detailed analysis."
      },
      "typeVersion": 1
    },
    {
      "id": "82472e40-7132-40ac-9c9b-4635f604d92a",
      "name": "Sticky Note Filter & Analyze",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -600,
        120
      ],
      "parameters": {
        "width": 760,
        "height": 340,
        "content": "## Property Filtering & Analysis
Here we filter the properties based on criteria for high-potential leads (high equity %, absentee owners, etc.) and fetch detailed information about each property to prepare comprehensive reports for the sales team."
      },
      "typeVersion": 1
    },
    {
      "id": "4538e728-f86c-4cf3-a69e-ce42ca5bb83e",
      "name": "Sticky Note Notifications",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        180,
        -40
      ],
      "parameters": {
        "width": 440,
        "height": 500,
        "content": "## Notifications
This section delivers the property leads to the sales team through multiple channels:

1. Email alerts with detailed property and owner information
2. Slack notifications for quick updates

Both include Google Maps links to quickly view the property location."
      },
      "typeVersion": 1
    },
    {
      "id": "4e09ea20-a6a3-4e6c-a67c-95cbd79f9151",
      "name": "Sticky Note Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1660,
        -220
      ],
      "parameters": {
        "width": 1040,
        "height": 300,
        "content": "## Setup Instructions

1. **API Keys & Credentials**:
   - Add your BatchData API Key to the BatchData API Configuration node
   - Set up SMTP credentials for email delivery
   - Configure Slack API credentials for team notifications

2. **Customize Search Parameters**:
   - Adjust property search criteria in the BatchData API Configuration node
   - Modify the filtering conditions in the Filter High Potential node

3. **Notification Recipients**:
   - Update email recipients in the Send Email Alert node
   - Set appropriate Slack channel in the Post to Slack node"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "21dfe7cd-d858-4954-a4da-b0dd11d17aff",
  "connections": {
    "Compare Results": {
      "main": [
        [
          {
            "node": "Split Properties",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Properties": {
      "main": [
        [
          {
            "node": "Filter High Potential",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Email Content": {
      "main": [
        [
          {
            "node": "Send Email Alert",
            "type": "main",
            "index": 0
          },
          {
            "node": "Post to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Previous Results": {
      "main": [
        [
          {
            "node": "Compare Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Property Details": {
      "main": [
        [
          {
            "node": "Format Email Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Market Scan": {
      "main": [
        [
          {
            "node": "BatchData API Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter High Potential": {
      "main": [
        [
          {
            "node": "Get Property Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Query BatchData Properties": {
      "main": [
        [
          {
            "node": "Get Previous Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "BatchData API Configuration": {
      "main": [
        [
          {
            "node": "Query BatchData Properties",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

功能特点

  • 自动检测新邮件
  • AI智能内容分析
  • 自定义分类规则
  • 批量处理能力
  • 详细的处理日志

技术分析

节点类型及作用

  • Scheduletrigger
  • Set
  • Httprequest
  • Code
  • Splitout

复杂度评估

配置难度:
★★★★☆
维护难度:
★★☆☆☆
扩展性:
★★★★☆

实施指南

前置条件

  • 有效的Gmail账户
  • n8n平台访问权限
  • Google API凭证
  • AI分类服务订阅

配置步骤

  1. 在n8n中导入工作流JSON文件
  2. 配置Gmail节点的认证信息
  3. 设置AI分类器的API密钥
  4. 自定义分类规则和标签映射
  5. 测试工作流执行
  6. 配置定时触发器(可选)

关键参数

参数名称 默认值 说明
maxEmails 50 单次处理的最大邮件数量
confidenceThreshold 0.8 分类置信度阈值
autoLabel true 是否自动添加标签

最佳实践

优化建议

  • 定期更新AI分类模型以提高准确性
  • 根据邮件量调整处理批次大小
  • 设置合理的分类置信度阈值
  • 定期清理过期的分类规则

安全注意事项

  • 妥善保管API密钥和认证信息
  • 限制工作流的访问权限
  • 定期审查处理日志
  • 启用双因素认证保护Gmail账户

性能优化

  • 使用增量处理减少重复工作
  • 缓存频繁访问的数据
  • 并行处理多个邮件分类任务
  • 监控系统资源使用情况

故障排除

常见问题

邮件未被正确分类

检查AI分类器的置信度阈值设置,适当降低阈值或更新训练数据。

Gmail认证失败

确认Google API凭证有效且具有正确的权限范围,重新进行OAuth授权。

调试技巧

  • 启用详细日志记录查看每个步骤的执行情况
  • 使用测试邮件验证分类逻辑
  • 检查网络连接和API服务状态
  • 逐步执行工作流定位问题节点

错误处理

工作流包含以下错误处理机制:

  • 网络超时自动重试(最多3次)
  • API错误记录和告警
  • 处理失败邮件的隔离机制
  • 异常情况下的回滚操作